package com.example.menulhd;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

public class RightAdapter extends BaseAdapter {
    private Context mContext;
    private List<FoodBean> list;

    public RightAdapter(Context mContext, List<FoodBean> list) {
        this.mContext = mContext;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup partnt) {
        View view1=View.inflate(mContext,R.layout.list_item,null);
        ((TextView)view1.findViewById(R.id.tv_name)).setText(list.get(i).getName());
        ((TextView)view1.findViewById(R.id.tv_price)).setText(list.get(i).getPrice());
        ((TextView)view1.findViewById(R.id.tv_sale)).setText(list.get(i).getSales());
        ((ImageView)view1.findViewById(R.id.iv_img)).setBackgroundResource(list.get(i).getImg());

        return view1;
    }
}
